<?php

$oSecurity = App::getModuleService('Account', 'Security');

$oTpl = &App::getTemplate();

require_once App::getParam('path') . "site/admin/frames/menu.php";

//remove restricted menu items for non-admins
if (!$oSecurity->isAdmin())
{
	$aPerms = $oSecurity->getStaffListing();
	$aCachePerms = array();
	foreach($aPerms as $iKey => $aPerm)
	{
		$aCachePerms[$aPerm['code']] = $aPerm['val'];
	}

    foreach($aMenu as $sMenuKey => $aMenuBlock)
    {
        foreach($aMenuBlock['items'] as $k => $v)
        {
            if ( isset($aCachePerms[$k]) && !$aCachePerms[$k] )
            {
                unset($aMenu[$sMenuKey]['items'][$k]);
            }
        }
    }

    foreach($aMenu as $sMenuKey=>$aMenuBlock)
    {
        if (!$aMenuBlock['items'])
        {
            unset($aMenu[$sMenuKey]);
        }

    }
}

(($sHook = App::getHook('AdminMenu')) ? eval($sHook) : false);

if ( !isset($_COOKIE['phpfox_no_warning']) )
{
	unset($aMenu['extra']['items']['admin.frames.main.warning_on']);
}

if (App::hasModule('Music') && !App::checkUploadParams(App::getParam('Mod_Music.max_song_size')))
{
    unset($aMenu['sections']['items']['admin.sections.music']);
}

if ($oSecurity->isStaff(null, true))
{
    unset($aMenu['config']['items']['admin.config.staff']);
}

unset($aMenu['plugins']);

$oCompMenu = &App::getModuleComponent('Menu', 'AdminMenu', array('aMenu' => $aMenu));
$srcMenu = $oCompMenu->process();

$oTpl->assignSrc(array(
    'srcMenu'        => $srcMenu,
));

$oTpl->assignSrc(array
(
	'plugin_admin_links' => ($oSecurity->isStaffAllowed('admin.plugins') ? phpFoXPlugins::create_admin_links() : ''),
	'plugin_header' => phpFoXPlugins::create_header(),
));

$oTpl->setTemplateFile('left.html');

global $_CONF;

$_CONF['debug'] = false;

?>
